﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="InitReceiptMasterForm.aspx.cs"
    Inherits="PSS.WebSite.FundManage.InitReceiptMasterForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>收款单主界面</title>
    <script src="../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
        <table>
            <tr>
                <td align="right">
                    单据编号：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="ReceiptSingleNo" class="mini-textbox" emptytext="请输入单据编号" style="width: 150px;"
                        onenter="onKeyEnter" />
                </td>
                <td align="right">
                    销货单位：
                </td>
                <td style="width: 150px;" align="left">
                    <div id="CustomerId" name="CustomerId" class="mini-combobox" style="width: 150px;"
                        popupwidth="250px" textfield="CustomerName" valuefield="CustomerId">
                        <div property="columns">
                            <div header="销货单位编号" field="CustomerCode" width="40%">
                            </div>
                            <div header="销货单位名称" field="CustomerName" width="60%">
                            </div>
                        </div>
                    </div>
                </td>
                <td style="width: 100px;">
                    <a class="mini-button" iconcls="icon-search" onclick="search()">查 询</a>
                </td>
            </tr>
            <tr>
                <td align="right">
                    单据日期：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="ReceiptSingleDateFrom" style="width: 150px;" class="mini-datepicker" format="yyyy-MM-dd" />
                </td>
                <td align="right">
                    至：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="ReceiptSingleDateEnd" style="width: 150px;" class="mini-datepicker" format="yyyy-MM-dd" />
                </td>
                <td style="width: 100px;">
                    <a class="mini-button" iconcls="icon-reset" onclick="reset()">重 置</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
        <table style="width: 100%;">
            <tr>
                <td style="width: 100%;">
                    <a class="mini-button" id="add" iconcls="icon-add" onclick="add();" plain="true">添加</a>
                    <a class="mini-button" id="edit" iconcls="icon-edit" onclick="edit()" plain="true">编辑</a>
                    <a class="mini-button" iconcls="icon-remove" id="remove" onclick="remove()" plain="true">
                        删除</a> <span class="separator"></span><a class="mini-button" onclick="close()" iconcls="icon-close"
                            plain="true">关闭</a>
                </td>
            </tr>
        </table>
    </div>
    <!--撑满页面-->
    <div class="mini-fit">
        <div id="grid1" class="mini-datagrid" style="width: 100%; height: 100%;" idfield="InitReceiptId"
            sizelist="[10,20,50,100]" pagesize="20">
            <div property="columns">
                <div type="indexcolumn">
                </div>
                <div field="ReceiptSingleDate" width="90" headeralign="center" allowsort="true" dateformat="yyyy-MM-dd">
                    单据日期
                </div>
                <div field="ReceiptSingleNo" width="120" headeralign="center" allowsort="true">
                    单据编号
                </div>
                <div field="CustomerName" width="140" headeralign="center" allowsort="true">
                    销货单位
                </div>
                <div field="TotalReceivableMoney" width="120" headeralign="center" allowsort="true">
                    收款金额
                </div>
                <div field="Remark" width="250" headeralign="center" allowsort="true">
                    备注
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        mini.parse();
        var now = new Date();
        var nowYear = now.getFullYear();
        var nowMonth = now.getMonth();
        var receiptSingleDateFrom = mini.get("ReceiptSingleDateFrom");
        receiptSingleDateFrom.setValue(new Date(nowYear, nowMonth, 1));
        var receiptSingleDateEnd = mini.get("ReceiptSingleDateEnd");
        receiptSingleDateEnd.setValue(new Date());

        var CustomerId = mini.get("CustomerId");
        CustomerId.setUrl("../Service/SetManageHandler.ashx?action=GetCustomerListByCombobox");
        var grid = mini.get("grid1");
        grid.setUrl("../Service/FundManageHandler.ashx?action=GetInitReceiptList");
        grid.load({ ReceiptSingleDateFrom: receiptSingleDateFrom.getFormValue(), ReceiptSingleDateEnd: receiptSingleDateEnd.getFormValue() });
        function search(e) {
            var ReceiptSingleNo = mini.get("ReceiptSingleNo").getValue();
            var CustomerId = mini.get("CustomerId").getValue();
            var ReceiptSingleDateFrom = receiptSingleDateFrom.getFormValue();
            var ReceiptSingleDateEnd = receiptSingleDateEnd.getFormValue();
            grid.load({ ReceiptSingleNo: ReceiptSingleNo, CustomerId: CustomerId, ReceiptSingleDateFrom: ReceiptSingleDateFrom, ReceiptSingleDateEnd: ReceiptSingleDateEnd });
        }
        function onKeyEnter(e) {
            search();
        }
        function reset(e) {
            mini.get("ReceiptSingleNo").setValue("");
            mini.get("CustomerId").setValue("");
            receiptSingleDateFrom.setValue(new Date(nowYear, nowMonth, 1));
            receiptSingleDateEnd.setValue(new Date());
        }
        function add() {
            mini.open({
                url: "FundManage/InitReceiptInfoForm.aspx",
                title: "添加收款单", width: 800, height: 520,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "new" };
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        }
        function edit() {
            var row = grid.getSelected();
            if (row) {
                mini.open({
                    url: "FundManage/InitReceiptInfoForm.aspx",
                    title: "编辑收款单", width: 800, height: 520,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "edit", InitReceiptId: row.InitReceiptId };
                        iframe.contentWindow.SetData(data);

                    },
                    ondestroy: function (action) {
                        grid.reload();
                    }
                });

            } else {
                mini.alert("请选中一条记录!");
            }
        }
        function remove() {
            var row = grid.getSelected();
            if (row) {
                mini.confirm("您确定要删除:" + row.ReceiptSingleNo + "？", "确定？",
                        function (action) {
                            if (action == "ok") {
                                $.ajax({
                                    url: "../service/FundManageHandler.ashx?action=RemoveInitReceipt&InitReceiptId=" + row.InitReceiptId,
                                    success: function (text) {
                                        grid.reload();
                                    },
                                    error: function (jqXHR, textStatus, errorThrown) {
                                        alert(jqXHR.responseText);
                                    }
                                });
                            } else {
                                return false;
                            }
                        });

            } else {
                mini.alert("请选中一条记录!");
            }
        }
        function CloseWindow(action) {
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }
        function close() {
            CloseWindow("close");
        }
    </script>
</body>
</html>
